import tensorflow as tf
import numpy as np

t = tf.constant([[1.,2.,3.,],[4.,5.,6.]])

# index 索引
print('*'*30,'index','*'*30)
print(t)
print(t[:,1:])
print(t[:,1])

# ops 算子
print('*'*30,'ops','*'*30)
print(t+10)
print(tf.square(t))
print(t @ tf.transpose(t))

# numpy conversion 与numpy的转换
print('*'*30,'numpy conversion','*'*30)
print(t.numpy())  # 直接调用方法转换成array
print(np.square(t))  # 调用numpy函数转换成array
np_t = np.array([[1.,2.,3.],[4.,5.,6.]])
print(tf.constant(np_t))

# scalars 0维tensor 常数
print('*'*30,'scalars','*'*30)
t = tf.constant(3.14)
print(t)
print(t.numpy())
print(t.shape)

print('*'*60)